﻿

@inject IHttpService _httpService

<MDialog @bind-Value="Dialog"
         Width="800">
    <MDCard>
        <MCardTitle Class="text-h5">
            查看奖品
        </MCardTitle>
      
        <MCardText>
            @if (Model!=null)
            {
                @if (Model.Type == LotteryAwardType.ActivationCode)
                {
                    <span style="font-size:large;">激活码：@Model.Context</span>

                }
                else if (Model.Type == LotteryAwardType.RealThing)
                {
                    <span style="font-size:large;">单号：@Model.Context</span>

                }
            }
            else
            {
                <CnGalWebSite.Components.Progressings.ProgressingCard Style="min-height:200px;" />
            }
        </MCardText>
      
    </MDCard>
</MDialog>
@code {
    [Parameter]
    public long Id { get; set; }

    public PrizeViewModel Model { get; set; } = new PrizeViewModel();

    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }

    public string Text { get; set; }
    private IEnumerable<long> Value1 { get; set; }
    bool isReady = false;

    bool Dialog { get; set; }


    public async Task Refresh()
    {
        try
        {
            Dialog = true;
            StateHasChanged();
            Model = await _httpService.GetAsync<PrizeViewModel>("api/lotteries/GetUserPrize/" + Id);
            StateHasChanged();
        }
        catch (Exception ex)
        {
            await ErrorHandler.ProcessError(ex, "获取用户奖品失败");
        }
    }
}
